﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSWFG
    { 
        #region ==dwWFG===========
        public static readonly DependencyProperty dwWFGProperty = DependencyProperty.Register("dwWFG",
            typeof(DataRow), typeof(TSWFG),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwWFGChanged));
        public DataRow dwWFG
        {
            get
            {
                return (DataRow)GetValue(dwWFGProperty);
            }
            set
            {
                SetValue(dwWFGProperty, value);
            }
        }
        private static void OdwWFGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TSWFG;
            if (src != null)
            {
                DataRow row= (DataRow)e.NewValue;
                src.dwWFG = row; 
            }
        }
        #endregion
       
        public TSWFG()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            MV = new VICC_WFEVENTSGROUP();
            DataContext = MV;
            InitializeComponent(); 
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwWFG = dwMaster; 
        } 
       
        public override void LOADALL()
        {
            SResult = TMV.QueryICC_WFEVENTSGROUP(dwData, 9999);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                row["DES"] = Helpers.Helper.GetGB2312Value(row["DES"].ToString());
            }
            MergeData(SResult,false); 
        }
        public override void LOADBYAUF()
        {
            Locate("KEY", ORDERNUM);
            base.LOADBYAUF();
        } 
    }
}
